//
//  CheckNetTool.m
//  NLProjectFrameworkDemo
//
//  Created by iosdeveloper on 2020/4/27.
//  Copyright © 2020 yj_zhang. All rights reserved.
//

#import "MantisCheckNetTool.h"
#import <AFNetworking/AFNetworking.h>

@implementation MantisCheckNetTool
+(void)CheckisHasNet:(callBackNet)netBlock{
  __block  NSString*isHasNet=@"0";
    AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
    
    //设置监听
    [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        switch (status) {
            case AFNetworkReachabilityStatusUnknown:
            {
                isHasNet=@"0";
                !netBlock?:netBlock(isHasNet);
            }
                break;

            case AFNetworkReachabilityStatusNotReachable:
                 
                 {
                     isHasNet=@"0";
                    !netBlock?:netBlock(isHasNet);
                     
                 }
                break;

            case AFNetworkReachabilityStatusReachableViaWWAN:
                
                 {
                      isHasNet=@"1";
                    !netBlock?:netBlock(isHasNet);
                     
                 }
                break;

            case AFNetworkReachabilityStatusReachableViaWiFi:
              {
                    isHasNet=@"1";
                    !netBlock?:netBlock(isHasNet);
                   
               }
                break;
            default:
                break;
        }
    }];
    
    //开始监听
    [manager startMonitoring];
  
}





@end
